package com.zxy.controller;

import com.zxy.model.RolePermissions;
import com.zxy.model.Roles;
import com.zxy.model.RolesQuery;
import com.zxy.service.RolesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/roles")
public class RolesController {

    @Resource
    private RolesService rolesService;


    @GetMapping
    public List<Roles> select(RolesQuery rolesQuery) {
        return rolesService.select(rolesQuery);
    }

    @PostMapping
    public int insert(@RequestBody Roles roles) {
        return rolesService.insert(roles);
    }

    @PutMapping
    public int update(@RequestBody Roles roles) {
        return rolesService.update(roles);
    }

    @DeleteMapping
    public int delete(Integer id) {
        return rolesService.delete(id);
    }

    @PostMapping("/editPermission")
    public int insert(@RequestBody RolePermissions model) {
        return rolesService.editPermission(model);
    }
}